package com.mstore.service;

import java.util.ArrayList;
import java.util.List;

import com.mstore.dao.AccountAlipayGoodsDao;
import com.mstore.pojo.AccountAlipayGoods;

public class AccountAlipayGoodsService {

	private AccountAlipayGoodsDao accountAlipayGoodsDao;

	/**
	 * 保存 * @param accountAlipayGoods
	 */
	public void addAccountAlipayGoods(AccountAlipayGoods accountAlipayGoods) {
		accountAlipayGoodsDao.addAccountAlipayGoods(accountAlipayGoods);
	}

	/**
	 * 更新 * @param accountAlipayGoods
	 */
	public void updateAccountAlipayGoods(AccountAlipayGoods accountAlipayGoods) {
		accountAlipayGoodsDao.updateAccountAlipayGoods(accountAlipayGoods);
	}

	/**
	 * 通过企业id、goodId查询企业购买的商品 查询剩余使用次数或是否还在有效时间内
	 */
	public AccountAlipayGoods getAccountAlipayGoodsByEaIdAndGoodtype(Long eaId,
			String goodType) {
		Object object = accountAlipayGoodsDao
				.getAccountAlipayGoodsByEaIdAndGoodtype(eaId, goodType);
		return object == null ? null : (AccountAlipayGoods) object;
	}

	/**
	 * 查询企业购买的商品 * @param eaId
	 */
	public List<AccountAlipayGoods> getAccountAlipayGoodsByEaId(Long eaId) {
		List<AccountAlipayGoods> goods = new ArrayList<AccountAlipayGoods>();
		List<Object> list = accountAlipayGoodsDao
				.getAccountAlipayGoodsByEaId(eaId);
		for (Object object : list) {
			goods.add((AccountAlipayGoods) object);
		}

		return goods;
	}

	public AccountAlipayGoodsDao getAccountAlipayGoodsDao() {
		return accountAlipayGoodsDao;
	}

	public void setAccountAlipayGoodsDao(
			AccountAlipayGoodsDao accountAlipayGoodsDao) {
		this.accountAlipayGoodsDao = accountAlipayGoodsDao;
	}

}
